﻿using FreeSql;
using FreeSql.DataAnnotations;
using System.ComponentModel.DataAnnotations;

[Table(Name = "sys_tenant")]
[Index("{tablename}_idx_01", "Identifier", true)]
public class Tenant : BaseAddEntity, IBaseDisable, IBaseSoftDelete
{

    /// <summary>
    /// 名称
    /// </summary>
    [Display(Name = "名称")]
    [StringLength(50, MinimumLength = 1, ErrorMessage = ConstAnnotationMsg.StringLength)]
    public string Name { get; set; } = "";
    /// <summary>
    /// 联系人
    /// </summary>
    [Display(Name = "联系人")]
    public string Contact { get; set; } = "";


    /// <summary>
    /// 是否正常模式（试用期--》交费-->正常使用）
    /// </summary>
    public bool HasNormal { get; set; } = false;
    /// <summary>
    /// 手机
    /// </summary>
    [Display(Name = "手机")]
    public string Mobile { get; set; } = "";

    /// <summary>
    /// 说明
    /// </summary>
    [Display(Name = "说明")]
    [MaxLength(200, ErrorMessage = ConstAnnotationMsg.MaxLength)]
    public string? Description { get; set; }

    /// <summary>
    /// 
    /// </summary>
    [Column(StringLength = -1, MapType = typeof(string))]
    [JsonMap]
    public Jwt Jwt { get; set; } = new Jwt();

    /// <summary>
    /// 
    /// </summary>
    [Column(StringLength = -1, MapType = typeof(string))]
    [JsonMap]
    public DbConfig Db { get; set; } = new DbConfig();

    /// <summary>
    /// 
    /// </summary>
    public long DbId { get; set; }
    /// <summary>
    /// 是否正式版本
    /// </summary>
    public bool IsOfficial { get; set; }

    /// <summary>
    /// 到期时间
    /// </summary>
    public DateTime EndDate { get; set; }

    /// <summary>
    /// 
    /// </summary>
    public bool IsDeleted { get; set; }


    /// <summary>
    /// 租户编码
    /// </summary>
    [Display(Name = "租户编码")]
    [MaxLength(20, ErrorMessage = ConstAnnotationMsg.MaxLength)]
    public string Identifier { get; set; } = "";
    /// <summary>
    /// 
    /// </summary>
    public bool IsDisabled { get; set; }

    [JsonMap]
    public List<string>? Industries { get; set; }

    [JsonMap]
    public string[]? Modules { get; set; }
}

public class Jwt
{
    public string Secret { get; set; } = "";

    public string Issuer { get; set; } = "";

    public string Audience { get; set; } = "";
    public int ExpirationMinutes { get; set; } = 60;
}

public interface ITenant
{
    long? TenantId { get; set; }
}
